package org.example.mallsystem1104.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.mallsystem1104.entity.Good;
import org.example.mallsystem1104.entity.GoodStandard;
import org.example.mallsystem1104.entity.dto.GoodDTO;

import java.util.List;

@Mapper
public interface GoodMapper extends BaseMapper<Good> {


    @Select("select good.*,MIN(gs.price)*discount as price from good left join good_standard as gs on good.id=gs.good_id " +
            "where is_delete=0 and recommend=1 group by good.id order by price ASC")
    List<GoodDTO> findAllGoods();

    @Select("select * from good_standard where good_id=#{id}")
    List<GoodStandard> getStandardById(Long id);
}
